<?php

//调用model 层数据 进行组装 然后返回
namespace app\common\business;


class Demo
{

    /**
     * business 层通过getDemoDateByCategoryId 获取数据 进行组装
     * @param $categoryId
     * @return array
     */
    public function getDemoDateByCategoryId($categoryId)
    {
        $model = new \app\common\model\mysql\Demo();
        $datas = $model->getDemoDateByCategoryId($categoryId);
        if (empty($datas)) {
            return [];
        }
        //对数据进行组装
        $categorys = config("category");
        foreach ($datas as $key => $data) {
            $datas[$key]['category_name'] = $categorys[$data["category_id"]] ?? "其他";
        }
        return $datas;

    }

}